package com.heihx.api.client;

import com.heihx.entity.AddressBook;
import com.heihx.entity.User;
import com.heihx.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;

@FeignClient("user-service")
public interface UserClient {
    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @GetMapping("/user/user/{id}")
    @Tag(name = "根据id查询用户")
    Result<User> getUserById(@PathVariable Long id);

    /**
     * 根据id查询地址
     * @param id
     * @return
     */
    @GetMapping("/user/addressBook/{id}")
    @Operation(summary = "根据id查询地址")
    Result<AddressBook> getAddressById(@PathVariable Long id);

    /**
     * 统计用户数量
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/user/user/countByMap")
    @Operation(summary = "统计用户")
    Result<Long> countByMap(@RequestParam(value = "begin") LocalDateTime begin,
                            @RequestParam(value = "end") LocalDateTime end);
}
